package priv.bestbeat.cloud.api.gateway.configurations.security;

import com.fasterxml.jackson.core.JsonProcessingException;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.server.WebFilterExchange;
import org.springframework.security.web.server.authentication.ServerAuthenticationSuccessHandler;
import priv.bestbeat.cloud.api.gateway.utils.ReactiveServerHttpUtil;
import reactor.core.publisher.Mono;

/**
 * 用户认证成功处理器
 * @author 张渠钦
 * @date 2022/1/5 17:39
 */
public class UserAuthenticationSuccessHandler implements ServerAuthenticationSuccessHandler {
    @Override
    public Mono<Void> onAuthenticationSuccess(WebFilterExchange webFilterExchange, Authentication authentication) {
        ServerHttpResponse serverHttpResponse = webFilterExchange.getExchange().getResponse();
        return ReactiveServerHttpUtil.sendMono(serverHttpResponse,"4");
    }
}
